package com.jt.controller;

import com.jt.pojo.ItemCatParam;
import com.jt.service.ItemCatParamService;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/itemCatParam")
public class ItemCatParamController {
    @Autowired
    private ItemCatParamService itemCatParamService;

    /**
     * 获取列表
     * /findItemCatParamListByType?itemCatId=564&paramType=1
     * 参数：itemCatId,paramType
     * 返回值：SysResult
     */
    @GetMapping("/findItemCatParamListByType")
    public SysResult findItemCatParamListByType(ItemCatParam itemCatParam){
        List<ItemCatParam> paramList = itemCatParamService.findParamListByType(itemCatParam);
        return SysResult.success(paramList);
    }

    /**
     * 请求路径: /itemCatParam/addItemCatParam
     * 请求类型: post
     * 业务描述: 实现商品分类参数新增操作
     * 请求参数: 使用itemCatParam对象接收
     */
    @PostMapping("/addItemCatParam")
    public SysResult addItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.addItemCatParam(itemCatParam);
        return SysResult.success();
    }

    /**
     * - 请求路径: /itemCatParam/updateItemCatParam
     * - 请求类型: put
     * - 请求参数: 使用itemCatParam对象接收
     */
    @PutMapping("/updateItemCatParam")
    public SysResult updateItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.updateItemCatParam(itemCatParam);
        return SysResult.success();
    }
    /**
     * 请求路径: /itemCatParam/deleteItemCatParamById?paramId=20
     * 请求类型: delete
     */
    @DeleteMapping("/deleteItemCatParamById")
    public SysResult deleteItemCatParamById(Integer paramId){
        itemCatParamService.deleteItemCatParamById(paramId);
        return SysResult.success();
    }
}
